from common.app_info import PhoneBy


class APPageELE:

    # 首页左上角黑体智慧生活/云智连,用于检测是否在首页
    HOME_PAGE = (PhoneBy.AccessibilityId, ['添加设备', 'home_screen_title', 'home_screen_bind_device'])
    # 家庭
    FAMILY = (PhoneBy.AccessibilityId, 'HomeNavigatorTab')
    CURRENT_HOME_IGNORE = (PhoneBy.AccessibilityId, '忽略该设备')
    # 右上角-添加设备的 + 需要到首页后下拉页面
    HOME_ADD_DEVICE = (PhoneBy.AccessibilityId, 'home_screen_bind_device')
    # 点右上角添加设备弹框-添加设备
    HOME_ADD_MENU_ADD = (PhoneBy.AccessibilityId, 'home_screen_bind_device_add')
    # 按分类添加设备
    ADD_DEVICES_BY_CATEGORY = (PhoneBy.AccessibilityId, '按分类添加设备')
    CAMERA_TYPE = (PhoneBy.AccessibilityId, '摄像机')

    CHANGE_BING_TYPE_BTN = (PhoneBy.XPATH, ['//*[@text="切换配网方式"]', '//*[@content-desc="AP热点配网"]', '//*[@content-desc="二维码配网"]'])

    BIND_TYPE_BLUE = (PhoneBy.XPATH, ['//*[@text="蓝牙配网"]', '//*[@content-desc="蓝牙配网"]'])
    BIND_TYPE_SOUND = (PhoneBy.XPATH, '//*[@text="声波配网"]')
    BIND_TYPE_LINE = (PhoneBy.XPATH, '//*[@text="有线配网"]')
    BIND_TYPE_WIFI = (PhoneBy.XPATH, ['//*[@text="通过WiFi进行配网"]', '//*[@text="AP热点配网"]', '//*[@content-desc="AP热点配网"]'])
    BIND_TYPE_QR = (PhoneBy.XPATH, ['//*[@text="二维码配网"]', '//*[@content-desc="二维码配网"]'])
    BIND_TYPE_4G = (PhoneBy.XPATH, '//*[@text="4G"]')
    BIND_TYPE_WIFI2 = (PhoneBy.XPATH, '//*[@resource-id="android:id/content"]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[3]')

    I_KNOW = (PhoneBy.XPATH, ['//*[@resource-id="com.qihoo.smart:id/sdl_button_negative"]', '//*[@resource-id="com.visualworld.cloudsmart:id/sdl_button_negative"]', '//*[@resource-id="com.visualworld.ecology:id/sdl_button_negative"]'])
    NEAR = (PhoneBy.XPATH, ['//*[@resource-id="com.qihoo.smart:id/cdb_i_know"]', '//*[@resource-id="com.visualworld.cloudsmart:id/cdb_i_know"]', '//*[@resource-id="com.visualworld.ecology:id/cdb_i_know"]'])

    def get_Aid_by_pk(self, pk):
        return [(PhoneBy.AccessibilityId, 'bind_product_toc_'+str(pk)), (PhoneBy.AccessibilityId, 'bind_product_tob_'+str(pk))]

    # CHECKBOX_ = (PhoneBy.XPATH, '//*[@resource-id="has-read"]')
    # CHECKBOX_ = (PhoneBy.ID, "has-read")
    CHECKBOX_ = (PhoneBy.CLASS_NAME, 'android.widget.CheckBox')

    # NEXTBTN1 = (PhoneBy.XPATH, "//android.widget.Button")
    NEXTBTN1 = (PhoneBy.XPATH, ['//*[@text="下一步"]', '//*[@text="开始配网"]', '//*[@content-desc="下一步"]'])
    DEVICE_CONNECT_WIFI = (PhoneBy.ID, ['com.qihoo.smart:id/btn_device_connect_wifi', 'com.visualworld.cloudsmart:id/btn_device_connect_wifi', 'com.visualworld.ecology:id/btn_device_connect_wifi'])
    SEARCH_TRY_FIND = (PhoneBy.ID, ['com.qihoo.smart:id/cdb_retry', 'com.visualworld.cloudsmart:id/cdb_retry', 'com.qihoo.smart:id/btn_device_scan', 'com.visualworld.cloudsmart:id/btn_device_scan', 'com.visualworld.ecology:id/cdb_retry', 'com.visualworld.ecology:id/btn_device_scan'])

    WIFI_NAME = (PhoneBy.ID, ['com.qihoo.smart:id/et_id', 'com.visualworld.cloudsmart:id/et_id', 'com.visualworld.ecology:id/et_id'])
    WIFI_PWD = (PhoneBy.ID, ['com.qihoo.smart:id/et_pw', 'com.visualworld.cloudsmart:id/et_pw', 'com.visualworld.ecology:id/et_pw'])
    NEXTBTN2 = (PhoneBy.ID, ['com.qihoo.smart:id/btn_next', 'com.visualworld.cloudsmart:id/btn_next', 'com.visualworld.ecology:id/btn_next'])
    BIND_SUCCESS = (PhoneBy.XPATH, '//*[@content-desc="开始体验"]')
    BIND_FAIL = (PhoneBy.XPATH, ["//*[@text='切换配网方式']", "//*[@text='上传日志']", "//*[@text='重新配网']", "//*[@text='再试一次']", '//*[@content-desc="绑定失败"]', '//*[@content-desc="重试"]'])

    # 发送声波-勾选
    SOUND_CHECKBOX_BTN = (PhoneBy.ID, ['com.qihoo.smart:id/cb_confirm', 'com.visualworld.cloudsmart:id/cb_confirm', 'com.visualworld.ecology:id/cb_confirm'])
    SEND_SOUND_BTN = (PhoneBy.ID, ['com.qihoo.smart:id/cdb_send_sound', 'com.visualworld.cloudsmart:id/cdb_send_sound', 'com.visualworld.ecology:id/cdb_send_sound'])

    CONNECT_AP_BTN = (PhoneBy.CLASS_NAME, 'android.widget.Button')  # AP热点链接按钮

    # 	已听到设备发出接收成功提示音
    GET_DEVICE_BEEP = (PhoneBy.ID, ['com.visualworld.cloudsmart:id/btn_receive_success', 'com.visualworld.ecology:id/btn_receive_success', 'com.qihoo.smart:id/btn_receive_success'])

    SETTING_NEW = (PhoneBy.AccessibilityId, '设置')
    DELETE_DEVICE = (PhoneBy.AccessibilityId, '删除设备')
    # 删除设备并清除全部用户信息、继续删除
    DELETE_AND_CLEAN = (PhoneBy.XPATH, ['//*[@content-desc="删除设备并清除全部用户信息"]', '//*[@content-desc="dialog_button_positive"]', '//*[@content-desc="仅删除设备"]', '//*[@content-desc="删除设备"]'])

    # 开流
    # 首页设备的开流窗口 （没有实时画面按钮-AI技能等）
    # DEVICE_FLOW_WINDOW = (PhoneBy.XPATH, '//*[contains(@content-desc,"card_")]')
    # DEVICE_FLOW_WINDOW = (PhoneBy.XPATH, "//*[not(contains(@content-desc,'_card')) and (contains(@content-desc,'card_'))]/android.view.View/android.widget.ImageView[1]")
    # DEVICE_FLOW_WINDOW = (PhoneBy.AccessibilityId, ['live_stream', 'cloud_record', 'settings', 'ai_skills'])
    DEVICE_FLOW_WINDOW = (PhoneBy.XPATH, "//*[not(contains(@content-desc,'_card')) and (contains(@content-desc,'card_'))]/android.view.View/android.widget.ImageView[1]")
    def get_home_item(self, item):
        return (PhoneBy.XPATH, f'//*[@content-desc="{item}"]')



    # 首页设备进入开流页
    COMBINE_ELE = (PhoneBy.AccessibilityId, ['ai_skills', 'camera_traffic_management'])
    # 实时画面
    START_PLAY = (PhoneBy.AccessibilityId, 'live_stream')
    # 视频播放窗口
    VIDEO_WIN = (PhoneBy.AccessibilityId, 'camera_player_live')
    # 通话按钮
    CALL_BUTTON = (PhoneBy.AccessibilityId, ['camera_rtc_duplex', 'camera_rtc_half_duplex'])
    # 分辨率切换按钮
    QUALITY_BUTTON = (PhoneBy.AccessibilityId, 'camera_player_clarity')
    # 3k超清
    SUPER3K_QUALITY = (PhoneBy.AccessibilityId, 'camera_player_clarity_item_ClarityMode.ultraHigh3K')
    # 2.5k 超清
    SUPER25K_QUALITY = (PhoneBy.AccessibilityId, 'camera_player_clarity_item_ClarityMode.ultraHigh25')
    # 超清
    SUPER_QUALITY = (PhoneBy.AccessibilityId, 'camera_player_clarity_item_ClarityMode.ultraHigh')
    # 高清
    HIGH_QUALITY = (PhoneBy.AccessibilityId, 'camera_player_clarity_item_ClarityMode.high')
    # 流畅
    SMOOTH_QUALITY = (PhoneBy.AccessibilityId, 'camera_player_clarity_item_ClarityMode.smooth')
    # 标清
    STANDARD_QUALITY = (PhoneBy.AccessibilityId, 'camera_player_clarity_item_ClarityMode.standard')
    # 自动
    AUTO_QUALITY = (PhoneBy.AccessibilityId, 'camera_player_clarity_item_ClarityMode.auto')

    # 卡录像
    # 卡录像按钮-摄像机&门铃通用
    CARD_PAGE_BUTTON = (PhoneBy.AccessibilityId, ['camera_tab_card_record', 'camera_portrait_tab_card_record'])

    # 卡录像页面判断开流成功--视频加载中不存在即表示开流成功
    FLOW_PAGE_LOADING = (PhoneBy.AccessibilityId, 'camera_progress')
    # 卡录开流加载成功（录制按钮能点击）
    RECORD_PLAY_SUCCESS = (PhoneBy.AccessibilityId, 'camera_player_record')

    # 我的
    MYSELF = (PhoneBy.AccessibilityId, 'ProfileNavigatorTab')
    # 设置按钮
    MYSELF_SETTING = (PhoneBy.AccessibilityId, 'navbar_set')
    # 关于 app
    MYSELF_ABOUT_APP = (PhoneBy.AccessibilityId, 'user_profile_item_about_app')
    # 关于页面-log
    ABOUT_ICON = (PhoneBy.AccessibilityId, 'sh_activity_about_icon')

    # 首页-设备卡片上的云录像按钮
    HOME_CLOUD_FLOW_BUTTON = (PhoneBy.AccessibilityId, 'cloud_record')
    # 云录-右上角 设置 icon
    CLOUD_SETTING = (PhoneBy.AccessibilityId, 'camera_cloud_record_to_device_settings')

    # 首页设备-设置
    HOME_ITEM_SETTING = (PhoneBy.AccessibilityId, 'settings')

    # 固件升级
    SETTING_DEVICE_UPGRADE = (PhoneBy.AccessibilityId, 'device_common_rom_upgrade')
    UPGRADE_NOW = (PhoneBy.XPATH, '//*[@content-desc="马上升级"]')
    LAST_VERSION = (PhoneBy.XPATH, ['//*[@content-desc="固件已经是最新版本"]', '//*[@content-desc="升级检测"]'])
    UPLOAD_TRY_AGAIN = (PhoneBy.XPATH, '//*[@content-desc="重试"]')

    # 门锁按门铃通知页面
    LOCK_PUSH_PAGE = (PhoneBy.XPATH, ['//*[@content-desc="接听"]', '//*[@content-desc="挂断"]'])

    # 门锁OTA 低版本标识
    LOCK_LOW_VERSION_TEXT = (PhoneBy.XPATH, ['//*[@content-desc="- 虚高版本，实际回退"]', '//*[@content-desc="- 虚高版本，实际回退\n- 虚高版本，实际回退"]'])
    # 门锁OTA 高版本标识
    LOCK_HIGH_VERSION_TEXT = (PhoneBy.XPATH, ['//*[@content-desc="- 优化功能，真实升级"]', '//*[@content-desc="- 优化功能，真实升级\n- 优化功能，真实升级"]'])
    # 门锁 内部门锁设置 按钮
    LOCK_SETTING = (PhoneBy.XPATH, '//*[@content-desc="门锁设置"]')


    """公共元素"""
    # 添加设备, 首页无设备
    HOME_NO_DEVICE = (PhoneBy.AccessibilityId, 'home_screen_empty_add_device')
    # 实时画面
    DOOR_LOCK_FLOW = (PhoneBy.AccessibilityId, ['doorlock_live_stream_item', 'doorlock_control_live_outdoor'])
    # 通话按钮
    DOOR_LOCK_CALL = (PhoneBy.AccessibilityId, ['camera_rtc_duplex', 'camera_rtc_half_duplex', 'doorlock_live_rtc_talk'])
    """智能门锁-首页卡片"""
    # 门锁首页卡片 中心点
    DOOR_LOCK_HOME = (PhoneBy.XPATH, '//*[@content-desc="home_screen_device_card_manage"]/following-sibling::*[1]')

    """门锁首页-右上角设置按钮"""
    # 右上角设置按钮
    # DOOR_LOCK_RIGHT_SETTING = (PhoneBy.XPATH, '//*[@content-desc="navbar_back"]/following-sibling::*[2]')
    DOOR_LOCK_RIGHT_SETTING = (PhoneBy.AccessibilityId, 'doorlock_control_settings')
    DEVICE_CARD_POINT = (PhoneBy.XPATH,
                         '//*[not(contains(@content-desc,"_card")) and (contains(@content-desc,"card_"))]//*[contains(@content-desc,"$$$")]')
    ENTER_DEVICE_REAL = (PhoneBy.XPATH, '//*[contains(@content-desc,"$$$")]//*[@content-desc="live_stream"]')
    ENTER_DEVICE_CLOUD = (PhoneBy.XPATH, '//*[contains(@content-desc,"$$$")]//*[@content-desc="cloud_record"]')
    ENTER_DEVICE_SETTING = (PhoneBy.XPATH, ['//*[contains(@content-desc,"$$$")]//*[@content-desc="settings"]',
                                            '//*[contains(@content-desc,"$$$")]//*[@content-desc="camera_cloud_record_to_device_settings"]',
                                            '//*[contains(@content-desc,"$$$")]//*[@content-desc="navbar_set"]'])